package net.tngou.iask.test;

import java.io.IOException;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import net.tngou.iask.util.StringUtil;

public class IDGet {

	public static void main(String[] args)  {
		while (true) {
			try {
				Document doc = Jsoup.connect("http://shenfenzheng.293.net/").data("id", "reload...").post();
				Element body = doc.body();
				Elements trs = body.getElementsByAttributeValue("bgcolor", "#FFFFFF");
				for (Element element : trs) {
					String td = element.getElementsByTag("td").first().text();
					if(StringUtil.isNotEmpty(td))
					{
						String[] tds = StringUtil.split(td, " ");
						if(tds.length==2)
						{
							System.err.println(tds[0]+":"+tds[1]);
							Document json = Jsoup.connect("http://127.0.0.1:8080/iask/api/patient/add")
							.data("access_token", "l76e380fc1b1fc2aa442e28d3fbffae8c50e29bc")
							.data("name", tds[0])
							.data("no", tds[1]).ignoreContentType(true).post();
							System.err.println(json);
						}
					}
				}
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
	 }
	}

}
